package com.kaka.bus.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.kaka.bus.R;
import com.kaka.bus.bean.BorrowList;
import com.kaka.bus.util.U;

import java.text.SimpleDateFormat;
import java.util.List;

/**
 * Created by zhangqi on 2017/12/25.
 * e-mail : ${email}
 * desc :
 */

public class BorrowListAdapter extends BaseQuickAdapter<BorrowList,BaseViewHolder> {

    public BorrowListAdapter(int layoutResId, @Nullable List<BorrowList> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, BorrowList item) {
//        String term = item.getProductTerm().getTerm();
        helper.setText(R.id.item_borrow_id,item.getBorrNum())
        .setText(R.id.item_borrowlist_price, U.connectString(item.getAmount(),"元"))
        .setText(R.id.item_borrow_statu,item.getStatusName());
        SimpleDateFormat format =  new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Long time=Long.valueOf(item.getAskDate());
        String d = format.format(time);
        helper.setVisible(R.id.img_tip, false);
        helper.setText(R.id.item_borrowlist_time,d);
        helper.setVisible(R.id.cancel_item, false).addOnClickListener(R.id.cancel_item);
        if (item.getBorrStatus().equals("BS001")||item.getBorrStatus().equals("BS002")){
            helper.setVisible(R.id.cancel_item, true);
        }
         if (item.getBorrStatus().equals("BS004")||item.getBorrStatus().equals("BS005")||item.getBorrStatus().equals("BS006")||item.getBorrStatus().equals("BS010")||item.getBorrStatus().equals("BS014")){
             helper.setVisible(R.id.img_tip, true);
        }


    }
}
